package src.twice;

import java.io.*;

public class Example_01 {
    public static void main(String[] args) {
        try {
            FileOutputStream fs = new FileOutputStream("C:\\Users\\22528\\Desktop\\he.txt");
            DataOutputStream ds = new DataOutputStream(fs);
            //ds.writeUTF("使用writerUTF()方法写入数据；");
            ds.writeChars("使用writerChars()方法写入数据：");
            //ds.writeBytes("使用writerBytes()方法写入数据");
            ds.close();
            fs.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        try {
            FileInputStream fis = new FileInputStream("C:\\Users\\22528\\Desktop\\he.txt");
            DataInputStream dis = new DataInputStream(fis);

            //System.out.println("UTF:"+dis.readUTF());

//            System.out.println("Byte:"+dis.readByte());
//            System.out.println("Char:"+dis.readChar());


            dis.close();
            fis.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
